﻿using Microsoft.AspNetCore.Mvc.Filters;

namespace FitterTest.Filters
{
    public class CtmActionFilter3Attribute : ActionFilterAttribute
    {
        private readonly ILogger<CtmActionFilter3Attribute> logger;

        /// <summary>
        /// 使用时 [TypeFilter(typeof(CtmActionFilter3Attribute))]
        /// </summary>
        /// <param name="logger"></param>
        public CtmActionFilter3Attribute(ILogger<CtmActionFilter3Attribute> logger)
        {
            this.logger = logger;
        }
        public override void OnActionExecuted(ActionExecutedContext context)
        {

            logger.LogWarning($"Action{context.ActionDescriptor.DisplayName} 执行完毕");
            base.OnActionExecuted(context);
        }

        public override void OnActionExecuting(ActionExecutingContext context)
        {

            logger.LogWarning($"Action{context.ActionDescriptor.DisplayName} 当前执行");
            base.OnActionExecuting(context);
        }
    }
}
